from django.contrib import admin

from .models import Article, Category, Tag


# Register your models here.
class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'author', 'category', 'postedBy', 'createTime')
    list_filter = ('createTime',)
    search_fields = ('title',)
    fieldsets = (
        (None, {"fields": ["title", "coverImage"]}),
        ("基本信息", {"fields": ["author", "postedBy", "createTime"]}),
        ("分类、标签", {"fields": ["category", "tags"], "classes": ["collapse"]}),
        ("正文", {"fields": ["content"]}),
    )


class CategoryAdmin(admin.ModelAdmin):
    list_display = ('category',)
    list_filter = ('category',)
    search_fields = ('category',)

class TagAdmin(admin.ModelAdmin):
    list_display = ('tag',)
    list_filter = ('tag',)
    search_fields = ('tag',)

admin.site.register(Article, ArticleAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Tag, TagAdmin)
